package org.example.controller;

import lombok.AllArgsConstructor;
import org.example.dao.Like;
import org.example.dao.Result;
import org.example.enums.responseEnum;
import org.example.service.LikeService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@AllArgsConstructor
@RestController
@RequestMapping("/like")
public class LikeController {

    private final LikeService likeService;

    @RequestMapping("/addLike")
    public Result addLike(@RequestBody Like like) {
        responseEnum res =likeService.addLike(like);
        if (res == responseEnum.success){
            return new Result(200,"点赞成功", null);
        }else {
            return new Result(500,"点赞失败", null);
        }
    }


    @RequestMapping("/deleteLike")
    public Result deleteLike(@RequestBody Like like) {
        responseEnum res =likeService.deleteLike(like);
        if (res == responseEnum.success){
            return new Result(200,"取消点赞成功", null);
        }else {
            return new Result(500,"取消点赞失败", null);
        }
    }



}
